package cn.mumzone.pos.presenter;

import cn.mumzone.basic.mvp.AbsPresenter;
import cn.mumzone.basic.mvp.BaseRepository;
import cn.mumzone.basic.util.RxBus;
import cn.mumzone.pos.event.MoreViewChangeEvent;
import cn.mumzone.pos.model.source.StockRepository;
import cn.mumzone.pos.presenter.contract.MoreViewContract;
import rx.Subscription;
import rx.functions.Action1;

/**
 * Created By Dlx
 * on 2019/10/21
 */
public class InitMoreViewPresenter extends AbsPresenter<MoreViewContract.View, StockRepository> implements MoreViewContract.Presenter {
    @Override
    public void initEvents() {
        Subscription moreViewChangeListener = RxBus.getDefault()
                .toObservable(MoreViewChangeEvent.class)
                .subscribe(new Action1<MoreViewChangeEvent>() {
                    @Override
                    public void call(MoreViewChangeEvent moreViewChangeEvent) {
                        if (moreViewChangeEvent.getType() == MoreViewChangeEvent.MORE_VIE_HOME)
                            mView.onBackEvent();
                    }
                });
        addSubscrebe(moreViewChangeListener);
    }
}
